#pragma once

#include "SvnVersion.h"
#include "svn_error.h"
//#define LOGS

// References:
// Pass String^ as char *: http://msdn2.microsoft.com/en-us/library/d1ae6tz5(VS.80).aspx
// Convert between string types: http://msdn2.microsoft.com/en-us/library/ms235631(VS.80).aspx
// Need to figure out debug warning: http://topic.csdn.net/t/20030710/10/2011282.html

// Seems like VC++ doesn't like some of the typedefs in APR and SVN
// which don't define a structure body. This only gives warnings,
// it doesn't actually affect the running of the program, but
// we go ahead and define them here to get rid of the warnings:
#include "fwd.h"

using namespace System;
using namespace System::Diagnostics;
using namespace System::Runtime::Serialization;

namespace IronSvn {

	[Serializable]
	public ref class Svn
	{
	public:
		Svn();
		static SvnVersion^ GetVersion();
		static void ThrowIfError(svn_error_t* error);
		static String^ GetError(svn_error_t* error);
		static String^ EnsureLocalPath(String^ path);
		static String^ PreparePath(String^ path);
		static apr_array_header_t *GetStringAsAprArray(const char *str, apr_pool_t *pool);
		static String^ SvnPathJoin(String^ base, String^ component);

		// returns UTC DateTime
		static DateTime^ ConvertAprTimeToDateTime(apr_time_t time);
#ifdef LOGS
		static bool^ IsLogEnabled;
#endif
	private:
	};

	[Serializable]
	public ref class SvnException : Exception
	{
	public:
		SvnException() : Exception() {}
		SvnException(String^ message) : Exception(message) {}
		SvnException(String^ message, Exception^ innerException) : Exception(message, innerException) {}

	protected:
		SvnException(SerializationInfo^ info, StreamingContext context) : Exception(info, context) {}
	};

	[Serializable]
	public ref class HttpdException : Exception
	{
	public:
		HttpdException() : Exception() {}
		HttpdException(String^ message) : Exception(message) {}
		HttpdException(String^ message, Exception^ innerException) : Exception(message, innerException) {}

	protected:
		HttpdException(SerializationInfo^ info, StreamingContext context) : Exception(info, context) {}
	};

	[Serializable]
	public enum class SvnSchedule
	{
		Normal,
		Add,
		Delete,
		Replace
	};
	
	[Serializable]
	public enum class SvnNodeKind
	{
		None,
		File,
		Directory,
		Unknown
	};

	[Serializable]
	public enum class SvnActionType
	{
		Add,
		Copy,
		Delete,
		Restore,
		Revert,
		FailedRevert,
		Resolved,
		Skip,
		UpdateDelete,
		UpdateAdd,
		UpdateUpdate,
		UpdateCompleted,
		UpdateExternal,
		StatusCompleted,
		StatusExternal,
		CommitModified,
		CommitAdded,
		CommitDeleted,
		CommitReplaced,
		CommitPostfixTxdelta,
		BlameRevision,
		Locked,
		Unlocked,
		FailedLock,
		FailedUnlock
	};

	[Serializable]
	public enum class SvnActionState
	{
		Inapplicable,
		Unknown,
		Unchanged,
		Missing,
		Obstructed,
		Changed,
		Merged,
		Conflicted
	};

	[Serializable]
	public enum class SvnLockState
	{
		Inapplicable,
		Unknown,
		Unchanged,
		Locked,
		Unlocked
	};

	[Serializable]
	public enum class SvnNodeAction
	{
		Add,
		Delete,
		Update
	};
}
